package com.ccbft.msgcenter.mc.filter.service.impl;

import com.ccbft.msgcenter.mc.filter.entity.ChainInstance;
import com.ccbft.msgcenter.mc.filter.entity.ChainNode;
import com.ccbft.msgcenter.mc.filter.mapper.ChainInstanceMapper;
import com.ccbft.msgcenter.mc.filter.service.IChainInstanceService;
import com.ccbft.msgcenter.mc.filter.service.IChainNodeService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author frank
 * @since 2019-07-20
 */
@Service
public class ChainInstanceServiceImpl extends ServiceImpl<ChainInstanceMapper, ChainInstance>
		implements IChainInstanceService {

	@Autowired
	private IChainNodeService chainNodeService;

	@Override
	public List<ChainNode> queryChainNodeListByInstanceId(Long chainInstanceId) {
		assert (chainInstanceId != null);
		List<ChainNode> chainList = chainNodeService.list(Wrappers.<ChainNode>lambdaQuery()
				.eq(ChainNode::getChainInstanceId, chainInstanceId)
				.orderByAsc(ChainNode::getOrderNum));
		return chainList;

	}

	public List<ChainNode> queryChainInstance(ChainInstance instance) {
		return this.queryChainNodeListByInstanceId(instance.getId());
	}
}
